#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n, k, x;
    cin >> n >> k >> x;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
    	cin >> a[i];
    }
    sort(a.begin(),a.end());
    priority_queue<pair<ll,ll>> pq;

    for(int i = 1; i < n; i++){
    	ll temp = a[i] - a[i - 1];
    	if(temp % 2 == 0){
    		pq.push({temp / 2, (a[i] + a[i - 1]) / 2});
    	}else{
    		if(temp == 1)continue;
    		pq.push({temp / 2,(a[i] + a[i - 1]) / 2});
    		pq.push({temp / 2,(a[i] + a[i - 1] + 1) / 2});
    	}
    }

    pq.push({a[0], 0});
    pq.push({x - a[n - 1], x});

    set<ll> res;
    set<ll> st;
    while(res.size() < k && !pq.empty()){
    	auto [val, pos] = pq.top();
    	// cout << pos << ' ';
    	pq.pop();
    	st.insert(pos);
    	if(val == 0)continue;
    	res.insert(pos);
    	ll p1 = pos - 1, p2 = pos + 1;
        if(p1 >= 0 && !st.count(p1)){
            auto it1 = upper_bound(a.begin(), a.end(), p1);
            if(it1 != a.begin()) it1--;
            else it1 = a.end();
            auto it2 = lower_bound(a.begin(), a.end(), p1);
            ll l = (it1 != a.end()) ? (p1 - *it1) : LLONG_MAX;
            ll r = (it2 != a.end()) ? (*it2 - p1) : LLONG_MAX;
            ll temp = min(l, r);
            if(temp > 0){
                pq.push({temp, p1});
                st.insert(p1);
            }
        }
        if(p2 <= x && !st.count(p2)){
            auto it1 = upper_bound(a.begin(), a.end(), p2);
            if(it1 != a.begin()) it1--;
            else it1 = a.end();
            auto it2 = lower_bound(a.begin(), a.end(), p2);
            ll l = (it1 != a.end()) ? (p2 - *it1) : LLONG_MAX;
            ll r = (it2 != a.end()) ? (*it2 - p2) : LLONG_MAX;
            ll temp = min(l, r);
            if(temp > 0){
                pq.push({temp, p2});
                st.insert(p2);
            }
        }
    }

    for(int i = 0; i < n; i++){
    	if(res.size() < k){
    		res.insert(a[i]);
    	}else{
    		break;
    	}
    }

    for(int x: res){
    	cout << x << ' ';
    }
    cout << '\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}